package com.card.game;

import java.util.Vector;

import com.card.user.User;
import com.card.user.UserUtils;

public class ZjhUtil {
	public static boolean isBaozi(Vector<Card> cards) {
		Card first = cards.get(0);
		for (int i = 1; i < cards.size(); i++) {
			if(first.getIndex() != cards.get(i).getIndex()) {
				return false;
			}
		}
		return true;
	}
	public static boolean isTongHua(Vector<Card> cards) {
		Card first = cards.get(0);
		for (int i = 1; i < cards.size(); i++) {
			if(cards.get(i).getType() != first.getType()) return false;
		}
		return true;
	}
	
	public static boolean isLianZi(Vector<Card> cards) {
		Card c1 = cards.get(0);Card c2 = cards.get(1);Card c3 = cards.get(2);
		boolean lianzi = c2.getIndex() - c1.getIndex() == 1
				&& c3.getIndex() - c2.getIndex() == 1;
		if(!lianzi && c3.getIndex() == 14) {
			c3 = new Card(c3.getType(), 1);
			lianzi = c2.getIndex() - c1.getIndex() == 1
					&& c1.getIndex() - c3.getIndex() == 1;
			if(lianzi) {
				cards.remove(2);
				cards.add(0,c3);
			}
		}
		return lianzi;
	}
	
	public static boolean isDui(Vector<Card> cards) {
		Card c1 = cards.get(0);Card c2 = cards.get(1);Card c3 = cards.get(2);
		return c1.getIndex() == c2.getIndex() || c3.getIndex() == c2.getIndex() ;
	}
	
	public static boolean is235Card(Vector<Card> cards) {
		Card c1 = cards.get(0);Card c2 = cards.get(1);Card c3 = cards.get(2);
		return c1.getIndex()==2 && c2.getIndex()==3 && c3.getIndex()==5;
	}
	
	public static void main(String[] args) {
		User user = UserUtils.getUserByImei("123");
		for (int i = 0; i < 100; i++) {
			Vector<Card> tableCards = CardUtils.createTGG();
			Vector<Card> cc = CardUtils.faPaiToVector(tableCards, 3);
			ZjhPlayer p = new ZjhPlayer(user);
			p.zjhInfo.isKanPai = true;
			p.initCards(cc);
			System.err.println("==============================");
			System.err.println(p.getType()+":"+p.getShowCards());
		}
	}
	
}
